import { defineConfig } from 'vite'
import { resolve } from "path";
import vue from '@vitejs/plugin-vue'

import ViteComponents, {ElementPlusResolver} from 'vite-plugin-components';

function pathResolve(dir: string){
  return resolve(__dirname, '.', dir)
}
export default defineConfig(({ mode })=> {
  return {
    plugins: [
      vue(),
      ViteComponents({
        // 按需加载element 另一种方式：https://www.cnblogs.com/guxingzhe/p/14892979.html
        customComponentResolvers: [
          ElementPlusResolver({
            importStyle: true
          })
        ]
      }),
    ],
    resolve: {
      alias: {
        '@': pathResolve('src')
      }
    }
  }
})